package com.gitee.feizns.explore.data_structure.linked_list.singly.flatten;

/**
 * @author feizns
 * @since 2019/10/9
 */
public class Node {

    int val;

    Node next, prev, child;

    public void print() {
        Node tmp = this;
        while ( tmp != null ) {
            System.out.print(tmp.val + ",");
            tmp = tmp.next;
        }
        System.out.println();
    }

    public void setNext(Node next) {
        this.next = next;
        if ( next != null )
            next.prev = this;
    }

    public Node(int val) {
        this.val = val;
    }

    @Override
    public String toString() {
        return "{" +
                "val:" + val +
                ", next:" + next +
                ", prev:" + prev +
                ", child:" + child +
                '}';
    }
}
